package com.suncaper.tddmall.service;

import com.suncaper.tddmall.common.model.User;
import com.suncaper.tddmall.common.model.User_address;
import com.suncaper.tddmall.common.model.User_addressExample;
import com.suncaper.tddmall.mapper.User_addressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    User_addressMapper user_addressMapper;
    @Override
    public List<User_address> searchByUserId(String userId) {
        User_addressExample user_addressExample = new User_addressExample();
        user_addressExample.createCriteria().andUserIdEqualTo(userId);
        List<User_address> user_addresses = user_addressMapper.selectByExample(user_addressExample);
        return user_addresses;
    }

    @Override
    public void updateByAddressId(User_address user_address) {
        user_addressMapper.updateByPrimaryKeySelective(user_address);
    }

    @Override
    public User_address searchByAddressId(String addressId) {
        User_address user_address = user_addressMapper.selectByPrimaryKey(addressId);
        return user_address;
    }


}
